﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Antu.WebControls;
using Antu.Core.Components;
using Antu.Core.Services;
using System.Web.UI.WebControls;
using System.Web;
using Antu.WorkFlowFactory;
using System.Data;

namespace WebSys.UI.OfficeFlow
{
    public class EditGroupSkin : MPBasicTemplate
    {
        FlowFactoryProvider _FlowFactoryProvider = (FlowFactoryProvider)ProviderService.ProviderServiceMange.GetProvider("FlowFactoryProvider");
        Button btnOk;
        TextBox txtGroupName;
        protected string UserId
        {
            get { if (base.Page.Session["UserId"] != null) { return base.Page.Session["UserId"].ToString(); } else { return string.Empty; } }
            set { base.Page.Session["UserId"] = value; }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            InitControl();
            if (!Page.IsPostBack)
            {
                string groupId = base.Page.Request["groupid"];
                if (!string.IsNullOrEmpty(groupId))
                {
                    txtGroupName.Text = _FlowFactoryProvider.GetOneStrString("st_group", "GROUP_NAME", "GROUPID", groupId);
                }
            }
        }
        private void InitControl()
        {
            txtGroupName = (TextBox)FindControl("txtGroupName");
            btnOk = (Button)FindControl("btnOk");
            btnOk.Click += new EventHandler(btnOk_Click);
        }

        protected void btnOk_Click(object sender, EventArgs e)
        {
            string groupId = base.Page.Request["groupid"];
            string groupName = txtGroupName.Text;
            bool save = _FlowFactoryProvider.UpdateGroupInfo(groupId, groupName);
            if (save) { Antu.Utilities.UtilitiesPage.AlertDialog("保存成功", "window.location.href('UserGrouplist.aspx');"); }
        }

    }
}


